package 树;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;

public class 面试题_17_12_BiNode {


    public TreeNode convertBiNode(TreeNode root) {
        TreeNode newTree = new TreeNode(root.val);
        Queue<TreeNode> queue = new LinkedList();
        queue.offer(root);
        while (!queue.isEmpty()) {
            TreeNode node = queue.poll();
            newTree.left = node.left;
            newTree.right = node.right;
            queue.offer(node.left);
            queue.offer(node.right);
        }
        return newTree;
    }
}
